package com.cheval.rpcframe.common;

import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Config {
    private static Logger logger = Logger.getLogger(Config.class);
    private static Properties properties;


    private static String serverType;
    private static String serverPath;


    /**
     * 加载rpc框架配置文件
     */
    static {
        InputStream is = Config.class.getClassLoader().getResourceAsStream("conf.properties");
        properties = new Properties();
        try {
            properties.load(is);
            setServerType();
            setServerPath();
        } catch (IOException e) {
            logger.error("加载配置文件失败", e);
        }
    }

    private static void setServerType() {
        String type = properties.getProperty("server.type");
        serverType = type;
    }

    public static String getServerType() {
        return serverType;
    }

    public static String getServerPath() {
        return serverPath;
    }

    public static void setServerPath() {
        String path = properties.getProperty("server.path");
        serverPath = path;
    }
}
